package richbar.com.richbar.view.dialog;

import android.app.Activity;
import android.app.AlertDialog;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.common.util.StringUtil;

import richbar.com.richbar.R;

/**
 * Created by QiYang on 2019/1/21.
 */

public class MaYiInputDialog {
    public void show(Activity mActivity, String content, final Callback callback) {
        AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
        View view = View.inflate(mActivity, R.layout.dialog_mayi_inpu, null);
        builder.setView(view);
        builder.setCancelable(false);
        TextView content_tv = view.findViewById(R.id.content);
        content_tv.setText(content);
        final EditText num = view.findViewById(R.id.num);
        TextView left_tv = view.findViewById(R.id.left_tv);
        TextView right_tv = view.findViewById(R.id.right_tv);
        final AlertDialog dialog = builder.create();
        left_tv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dialog.cancel();
            }
        });
        right_tv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!StringUtil.isEmpty(StringUtil.getStr(num))){
                    callback.onBesure(StringUtil.getStr(num));
                    dialog.cancel();
                }
            }
        });

        dialog.show();
    }

    public interface Callback{
        void onBesure(String num);
    }
}
